/*
 * @Description:
 * @Author: Chetwyn
 * @Date: 2019-05-20 14:28:38
 * @LastEditors: Chetwyn
 * @LastEditTime: 2019-08-30 16:59:51
 */
import { RNJumpModule } from 'react-native-cgws-support';

function assembleJumpInfo(type) {
  return function(bean) {
    let params = { type };
    params[type + 'Bean'] = bean;

    return JSON.stringify(params);
  };
}

// 跳转到IM聊天界面
export function jumpToImPage(imId) {
  let bean = {
    identity: 'imRoom',
    paramInfo: [{ key: 'uid', value: imId }],
  };

  let jumpInfo = assembleJumpInfo('native')(bean);
  RNJumpModule.jump(jumpInfo);
}

// 跳转到客户详情小程序
export function jumpToCustomerDetail(customerId) {
  // 新版本支持跳转到原生的客户全景
  const bean = {
    identity: 'customerPanoramic',
    paramInfo: [{ key: 'customerId', value: customerId }],
  };
  const jumpInfo = assembleJumpInfo('native')(bean);

  RNJumpModule.jump(jumpInfo);
}
